home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kopete / kopeteaway.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-10-01  |  5.6 KB  |  218 lines

  1. /*
  2.     kopeteaway.h  -  Kopete Away
  3.  
  4.     Copyright (c) 2002 by Hendrik vom Lehn <hvl@linux-4-ever.de>
  5.     Copyright (c) 2003 Olivier Goffart     <ogoffart @ kde.org>
  6.  
  7.     Kopete (c) 2002-2003 by the Kopete developers  <kopete-devel@kde.org>
  8.  
  9.     *************************************************************************
  10.     *                                                                       *
  11.     * This library is free software; you can redistribute it and/or         *
  12.     * modify it under the terms of the GNU Lesser General Public            *
  13.     * License as published by the Free Software Foundation; either          *
  14.     * version 2 of the License, or (at your option) any later version.      *
  15.     *                                                                       *
  16.     *************************************************************************
  17. */
  18.  
  19. #ifndef KOPETEAWAY_HI
  20. #define KOPETEAWAY_HI
  21.  
  22. #include <qstring.h>
  23. #include <qobject.h>
  24. #include <qvaluelist.h>
  25.  
  26. #include "kopeteawaydialog.h"
  27. #include "kopete_export.h"
  28.  
  29. class QStringList;
  30.  
  31. struct KopeteAwayPrivate;
  32.  
  33. class KopeteGlobalAwayDialog;
  34. class KopeteAwayDialog;
  35.  
  36. namespace Kopete
  37. {
  38.  
  39. /**
  40.  * @class Kopete::Away kopeteaway.h
  41.  *
  42.  * Kopete::Away is a singleton class that manages away messages
  43.  * for Kopete. It stores a global away message, as well as
  44.  * a list of user defined away messages.
  45.  * This class is used by KopeteAwayDialog, which gets it's
  46.  * list of user-defined away messages from this.  Protocol
  47.  * plugins' individual away dialogs should also get away
  48.  * messages from this object.
  49.  *
  50.  * It also handle global Idle Time, and all auto away stuff
  51.  *
  52.  * @author Hendrik vom Lehn <hvl@linux-4-ever.de>
  53.  * @author Chris TenHarmsel <tenharmsel@users.sourceforge.net>
  54.  * @author Olivier Goffart <ogoffart @ kde.org>
  55.  
  56.  */
  57. class KOPETE_EXPORT Away : public QObject
  58. {
  59. Q_OBJECT
  60.  
  61. friend class ::KopeteAwayDialog;
  62.  
  63. public:
  64.  
  65.     /**
  66.      * @brief Method to get the single instance of Kopete::Away
  67.      * @return Kopete::Away instance pointer
  68.      */
  69.     static Away *getInstance();
  70.  
  71.     /**
  72.      * @brief Gets the current global away message
  73.      * @return The global away message
  74.      */
  75.     static QString message();
  76.  
  77.     /**
  78.      * @brief Gets the current global auto away message
  79.      * @return The global auto away message
  80.      */
  81.     static QString autoAwayMessage();
  82.  
  83.     /**
  84.      * This method sets the global away message,
  85.      * it does not set you away, just sets the message.
  86.      * @brief Sets the global away message
  87.      * @param message The message you want to set
  88.      */
  89.     void setGlobalAwayMessage(const QString &message);
  90.  
  91.     /**
  92.      * This method sets the global auto away message,
  93.      * it does not set you away, just sets the message.
  94.      * @brief Sets the global auto away message
  95.      * @param message The message you want to set
  96.      */
  97.     void setAutoAwayMessage(const QString &message);
  98.  
  99.     /**
  100.      * @brief Sets global away for all protocols
  101.      */
  102.     static void setGlobalAway(bool status);
  103.  
  104.     /**
  105.      * @brief Indicates global away status
  106.      * @return Bool indicating global away status
  107.      */
  108.     static bool globalAway();
  109.  
  110.     /**
  111.      * @brief Function to get the titles of user defined away messages
  112.      * @return List of away message titles
  113.      *
  114.      * This function can be used to retrieve a QStringList of the away message titles,
  115.      * these titles can be passed to getMessage(QString title) to retrieve the
  116.      * corresponding message.
  117.      */
  118.     QStringList getMessages();
  119.  
  120.     /**
  121.      * @brief Function to get an away message
  122.      * @return The away message corresponding to the title
  123.      * @param messageNumber Number of the away message to retrieve
  124.      *
  125.      * This function retrieves the away message that corresponds to the ringbuffer index
  126.      * passed in.
  127.      */
  128.      QString getMessage( uint messageNumber );
  129.  
  130.      /**
  131.       * @brief Adds an away message to the ringbuffer
  132.       * @param message The away message
  133.       *
  134.       * This function will add an away message to the ringbuffer of user defined
  135.       * away messages.
  136.       */
  137.      void addMessage(const QString &message);
  138.  
  139.     /**
  140.      * time in seconds the user has been idle
  141.      */
  142.     long int idleTime();
  143.  
  144. private:
  145.     Away();
  146.     ~Away();
  147.  
  148.     /**
  149.      * @brief Saves the away messages to disk
  150.      *
  151.      * This function will save the current list of away messages to the disk
  152.      * using KConfig. It is called automatically.
  153.      */
  154.     void save();
  155.  
  156.     /**
  157.      * @brief Check for activity using X11 methods
  158.      * @return true if activity was detected, otherwise false
  159.      *
  160.      * Attempt to detect activity using a variety of X11 methods.
  161.      */
  162.     bool isActivity();
  163.  
  164.     //Away( const Away &rhs );
  165.     //Away &operator=( const Away &rhs );
  166.     static Away *instance;
  167.     KopeteAwayPrivate *d;
  168.  
  169. private slots:
  170.     void slotTimerTimeout();
  171.     void load();
  172.  
  173. public slots:
  174.     /**
  175.      * @brief Mark the user active
  176.      *
  177.      * Plugins can mark the user active if they discover activity by another way than the mouse or the keyboard
  178.      * (example, the motion auto away plugin)
  179.      * this will reset the @ref idleTime to 0, and set all protocols to available (online) if the state was
  180.      * set automatically to away because of idleness, and if they was previously online
  181.      */
  182.     void setActive();
  183.  
  184.     /**
  185.      * Use this method if you want to go in the autoaway mode.
  186.      * This will go autoaway even if the idle time is not yet reached. (and even if the user
  187.      * did not selected to go autoaway automaticaly)
  188.      * But that will go unaway again when activity will be detected
  189.      */
  190.     void setAutoAway();
  191.  
  192. signals:
  193.     /**
  194.      * @brief Activity was detected
  195.      *
  196.      * this signal is emit when activity has been discover after being autoAway.
  197.      */
  198.     void activity();
  199.  
  200.     /**
  201.      * @brief Default messages were changed
  202.      */
  203.     void messagesChanged();
  204. };
  205.  
  206. }
  207.  
  208. #endif
  209. /*
  210.  * Local variables:
  211.  * c-indentation-style: k&r
  212.  * c-basic-offset: 8
  213.  * indent-tabs-mode: t
  214.  * End:
  215.  */
  216. // vim: set noet ts=4 sts=4 sw=4:
  217.  
  218.